<div class="hbox hbox-auto-xs hbox-auto-sm" ng-init="
    app.settings.asideFolded = false;
    app.settings.asideDock = false;
  ">
    <!-- main -->
    <div class="col">
        <!-- main header -->
        <div class="bg-light lter b-b wrapper-md">
            <div class="row">
                <div class="col-sm-6 col-xs-12" ng-controller="playbookVersionCtrl">
                    <h1 class="m-n font-thin h3 text-black">AnsiblePlaybook配置
                        <button ng-click="playbookVersion()"
                                class="btn btn-xs"
                                style="margin-left: 5px; background-color: #00a8f3; color: white;">
                            <span class="icon icon-info"></span> Version
                        </button>
                    </h1>
                    <small class="text-muted">AnsiblePlaybook配置管理</small>
                </div>
            </div>
        </div>
        <!-- / main header -->
        <div class="wrapper-md">
            <!-- toaster directive -->
            <toaster-container
                    toaster-options="{'position-class': 'toast-top-right', 'close-button':true}"></toaster-container>
            <!-- / toaster directive -->

            <uib-tabset>
                <uib-tab index="0" heading="自动化Playbook配置">
                    <div class="panel panel-default" ng-controller="configPlaybookCtrl">
                        <div class="panel-body">
                            <div>
                                <form class="form-inline" role="form">
                                    <div class="form-group">
                                        <button
                                                type="button" class="btn btn-success" ng-click="queryPlaybook()"><span
                                                class="glyphicon glyphicon-repeat"></span>查询
                                        </button>

                                        <button type="button" class="btn btn-success"
                                                ng-click="addConfigPlaybook()"><span
                                                class="glyphicon glyphicon-plus"></span>新增
                                        </button>
                                    </div>
                                </form>
                            </div>
                            <div style="margin-top: 5px;">
                                <table class="table table-hover table-bordered table-striped">
                                    <thead>
                                    <tr>
                                        <td>配置文件</td>
                                        <td class="col-md-4">配置详情</td>
                                        <td>分组中的服务器</td>
                                        <td>操作</td>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr ng-repeat="item in playbookList">
                                        <td>
                                            <b style="color: #286090">{{item.configFileDO.fileName}}</b>
                                            <b class="pull-right">{{item.configFileDO.fileDesc}}</b>
                                        </td>
                                        <td>
                                            <b style="color: #286090">{{item.src}}</b>
                                            <b class="pull-right">源路径</b>
                                            </br>
                                            <b style="color: #286090">{{item.dest}}</b>
                                            <b class="pull-right">目标路径</b>
                                            </br>
                                            <b style="color: #286090">{{item.hostPattern}}</b>
                                            <b class="pull-right">分组HostPattern</b>
                                        </td>
                                        <td>
                                            <div class="col-md-6" ng-repeat="server in item.servers">
                                                <b style="color: #286090">
                                                    {{server.serverName}}-{{server.serialNumber}}<{{server.insideIp}}></b>
                                            </div>

                                        </td>
                                        <td>
                                            <!--<button ng-click="editItem(item)"-->
                                            <!--class="btn btn-xs"-->
                                            <!--ng-disabled="butEditDisabled"-->
                                            <!--style="margin-left: 5px; background-color: #2e6da4; color: white;">-->
                                            <!--<i class="glyphicon glyphicon-edit"></i>编辑-->
                                            <!--</button>-->

                                            <!--<button ng-click="launchItem(item.id)"-->
                                            <!--class="btn btn-xs"-->
                                            <!--style="margin-left: 5px; background-color: limegreen; color: white;">-->
                                            <!--<span class="glyphicon glyphicon-search"></span>预览-->
                                            <!--</button>-->

                                            <button ng-click="doPlaybook(item.id)"
                                                    class="btn btn-xs"
                                                    style="margin-left: 5px; background-color: limegreen; color: white;">
                                                <span class="glyphicon icon-control-play"></span>Playbook
                                            </button>

                                            <!--<button ng-click="invokeItem(item.id)" ng-show="false"-->
                                            <!--class="btn btn-xs"-->
                                            <!--ng-disabled="butInvokeDisabled"-->
                                            <!--uib-popover-html="'同步配置并生效'" popover-trigger="'mouseenter'"-->
                                            <!--style="margin-left: 5px; background-color: #ff5f87; color: white;">-->
                                            <!--<i class="fa fa-spin fa-spinner" ng-show="butInvokeSpinDisabled"></i>-->
                                            <!--<i class="icon icon-control-play" ng-show="!butInvokeSpinDisabled"></i>执行-->
                                            <!--</button>-->

                                            <button ng-click="delItem(item.id)"
                                                    class="btn btn-xs pull-right"
                                                    ng-disabled="butDelDisabled"
                                                    style="background-color: red; color: white;">
                                                <i class="glyphicon glyphicon-remove"></i>删除
                                            </button>
                                        </td>
                                    </tr>
                                    </tbody>
                                    <tfoot>
                                    <tr>
                                        <td colspan="10">
                                            <ul style="margin: 0px; float: right;" uib-pagination
                                                total-items="totalItems" ng-model="currentPage"
                                                items-per-page="pageLength" max-size="10" ng-change="pageChanged()"
                                                previous-text="&lsaquo;" next-text="&rsaquo;"></ul>
                                        </td>
                                    </tr>
                                    </tfoot>
                                </table>
                            </div>


                            <div style="font-size:0.5em;">&nbsp;</div>
                            <!--playbook结果-->
                            <div class="panel panel-info">
                                <!--style="background-color: #20a03f"-->
                                <div class="panel-heading">当前Playbook日志
                                    <span ng-if="playbookLog.complete != null" class="label">
                                              <i style="color: #00a8f3" class="fa fa-spin fa-spinner"
                                                 ng-show="!playbookLog.complete"></i>
                                              <b style="color: #00a8f3"
                                                 ng-show="!playbookLog.complete">Do Playbook ...</b>
                                        </span>
                                </div>
                                <form class="form-group" ng-if="playbookLog.complete">
                                    <div hljs hljs-source="playbookLog.playbookLog"></div>
                                </form>

                            </div>
                        </div>


                    </div>
                </uib-tab>
                <uib-tab index="1" heading="历史任务查询">
                    <div class="panel panel-default" ng-controller="playbookLogCtrl">
                        <div class="panel-body">
                            <div>
                                <form class="form-inline" role="form">
                                    <div class="form-group">
                                        <div class="input-group">
                                            <span class="input-group-addon">Playbook名称</span>
                                            <input type="text" class="form-control" ng-model="playbookName"
                                                   placeholder="名称">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="input-group">
                                            <span class="input-group-addon">操作人</span>
                                            <input type="text" class="form-control" ng-model="username"
                                                   placeholder="用户名">
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <button
                                                type="button" class="btn btn-success" ng-click="pageChanged()"><span
                                                class="glyphicon glyphicon-repeat"></span>查询
                                        </button>
                                    </div>
                                </form>
                            </div>
                            <div style="margin-top: 5px;">
                                <table class="table table-hover table-bordered table-striped">
                                    <thead>
                                    <tr>
                                        <td class="col-md-3">Playbook</td>
                                        <td>参数</td>
                                        <td class="col-md-2">操作</td>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr ng-repeat="item in pageData">
                                        <td>
                                            <b>{{item.playbookName}}</b>
                                            <b class="pull-right">名称</b>
                                            </br>
                                            <b style="color: #1e983b" ng-show="item.doType == 1">手动</b>
                                            <b style="color: #3abee8" ng-show="item.doType == 0">系统</b>
                                            <b class="pull-right">任务类型</b>
                                            </br>
                                            <b style="color: #1e983b" ng-show="item.complete">完成</b>
                                            <b style="color: #ff8700" ng-show="!item.complete">执行中</b>
                                            <b class="pull-right">状态</b>
                                            </br>
                                            <b style="color: #ff5f87">{{item.viewTime}}</b>
                                            <b class="pull-right">时间</b>
                                            <div ng-show="item.userDO != null ">
                                                <b style="color: #1b6d85">{{item.userDO.username}}<{{item.userDO.displayName}}></b>
                                                <b class="pull-right">执行人</b>
                                            </div>

                                        </td>
                                        <td>
                                            {{item.content}}
                                        </td>
                                        <td>
                                            <button ng-click="viewLog(item)"
                                                    class="btn btn-xs"
                                                    style="margin-left: 5px; background-color: #00a8f3; color: white;">
                                                <span class="glyphicon glyphicon-search"></span>查看
                                            </button>

                                            <button ng-click="delItem(item.id)"
                                                    class="btn btn-xs pull-right"
                                                    ng-disabled="butDelDisabled"
                                                    style="background-color: red; color: white;">
                                                <i class="glyphicon glyphicon-remove"></i>删除
                                            </button>
                                        </td>
                                    </tr>
                                    </tbody>
                                    <tfoot>
                                    <tr>
                                        <td colspan="10">
                                            <ul style="margin: 0px; float: right;" uib-pagination
                                                total-items="totalItems" ng-model="currentPage"
                                                items-per-page="pageLength" max-size="10" ng-change="pageChanged()"
                                                previous-text="&lsaquo;" next-text="&rsaquo;"></ul>
                                        </td>
                                    </tr>
                                    </tfoot>
                                </table>
                                <div class="form-group">
                                    <div ng-if="alert.type != ''">
                                        <div uib-alert ng-class="'alert-' + alert.type" close="closeAlert()">
                                            {{alert.msg}}
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </uib-tab>
            </uib-tabset>
        </div>
    </div>
    <!-- / main -->
</div>


<script type="text/ng-template" id="versionInfoModal">
    <div ng-include="'tpl/modal/ansible_version_info_modal.html'"></div>
</script>

<script type="text/ng-template" id="configPlaybookModal">
    <div ng-include="'tpl/modal/configFile/config_playbook_modal.html'"></div>
</script>


<!--查看Playbook日志-->
<script type="text/ng-template" id="playbookLogInfoModal">
    <div ng-include="'tpl/modal/playbook/playbook_log_info_modal.html'"></div>
</script>
